// pages/interact/interact.js
import { Base } from '../../utils/base.js';
import { Photo } from '../photo/photo-model.js';
var photo = new Photo();
var base = new Base();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    commentShow: false,
  },

  /**
   * 页面的初始数据
   */
  data: {
    commentShow: false,
    loadingHidden: false,
    commentsNum: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this._loadData();
  },

  onShow: function () {
    this._loadData();
  },

  _loadData: function () {
    var that = this;
    base.getUserInfo((data) => {
      that.setData({
        userInfo: data,
        loadingHidden: true
      });

    });

    photo.getNewComments((data) => {
      that.setData({
        commentsNum: data.num,
        comments: data.notice
      })
    })
  },

  petsPhotoTap: function (e) {
    var id = photo.getDataSet(e, 'id');
    wx.navigateTo({
      url: '../photo/photo?id=' + id + '&mine=1',
    })
  },

  onPostPhoto: function(e) {
    wx.navigateTo({
      url: '../post-photo/post-photo',
    })
  },
  
  toggleComment: function (e) {
    if (!this.data.commentShow) {
      this.setData({
        commentShow: true
      })
    } else {
      this.setData({
        commentShow: false
      })
    }
  },
})